package ch.unisi.inf.editor;

import java.awt.Color;
import ch.unisi.inf.engine.Image;
/**
 * subclass of the ImageInfo class, returns the average green content of the Image
 * 
 * @author matthias.eberli@lu.unisi.ch
 */
public class InfoGreen extends ImageInfo
{
    
    public InfoGreen(final String name)
    {
        super(name);
    }
    
    public int getInfo(final Image image)
    {
        int green = 0;
        final int height = image.getHeight();
        final int width = image.getWidth();
        for(int y = 0; y < height; y++) {
            for(int x = 0; x < width; x++) {
                Color pixel = image.getPixel(x, y);
                green += pixel.getGreen();
            }
        }
        green = green / (height * width);
        return green;
    }
}
